package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicWhCheckItemDAO;
import com.cssy.yd.logic.entity.LogicWhCheckItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-09-02
 */
public class LogicWhCheckItemDAOImpl extends SqlMapClientDaoSupport implements LogicWhCheckItemDAO {

    /**
     * 插入数据
     * @param logicWhCheckItemDO
     * @return 插入数据的主键
     */
    public String insertLogicWhCheckItemDO(LogicWhCheckItemDO logicWhCheckItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicWhCheckItem.insert", logicWhCheckItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicWhCheckItemDO
     * @return 查出的记录数
     */
    public Integer countLogicWhCheckItemDOByExample(LogicWhCheckItemDO logicWhCheckItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhCheckItem.countByDOExample", logicWhCheckItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWhCheckItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicWhCheckItemDO(LogicWhCheckItemDO logicWhCheckItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicWhCheckItem.update", logicWhCheckItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWhCheckItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWhCheckItemDO> findListByExample(LogicWhCheckItemDO logicWhCheckItemDO) throws DataAccessException {
        List<LogicWhCheckItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhCheckItem.findListByDO", logicWhCheckItemDO);
        return list;
    }

    /**
     * 根据主键获取logicWhCheckItemDO
     * @param id
     * @return logicWhCheckItemDO
     */
    public LogicWhCheckItemDO findLogicWhCheckItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicWhCheckItemDO logicWhCheckItemDO = (LogicWhCheckItemDO) getSqlMapClientTemplate().queryForObject("LogicWhCheckItem.findByPrimaryKey", id);
        return logicWhCheckItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWhCheckItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhCheckItem.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicWhCheckItemDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicWhCheckItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhCheckItem_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhCheckItem_ex.count", scs);
  	      return count;
  	}
	
	@Override
	public List<LogicWhCheckItemDO> findItemByCheckID(String checkID) throws DataAccessException{
		 List<LogicWhCheckItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhCheckItem_ex.findByCheckID", checkID);
	        return list;
	}
   	
}